package com.example.myapplication.slice;

import com.example.myapplication.ResourceTable;
import com.youth.banner.Banner;
import com.youth.banner.listener.OnBannerListener;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.ai.cv.text.Text;
import ohos.global.resource.NotExistException;
import ohos.global.resource.WrongTypeException;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class MainAbilitySlice extends AbilitySlice {
    private Banner main_banner;
    private List<String> title;
    private List<Integer> list;
    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_main);
        initview();
        initbanner();
    }

    private void initbanner() {
        try {
            list = new ArrayList<>();
            list.add(ResourceTable.Media_dj1);
            list.add(ResourceTable.Media_dj2);
            list.add(ResourceTable.Media_dj3);
            list.add(ResourceTable.Media_dj4);
            list.add(ResourceTable.Media_dj5);
            list.add(ResourceTable.Media_dj6);
            title = new ArrayList<>();
            title.add("永远跟党走");
            title.add("习主席讲话");
            title.add("党建学习");
            title.add("不忘初心，牢记使命");
            title.add("党建活动");
            title.add("党员主题日");
            main_banner.setImages(list).setBannerTitles(title).setScaleType(1).setDelayTime(3000).setBannerStyle(5).setTitleTextSize(60);
            main_banner.start();
//            main_banner.setOnBannerListener(new OnBannerListener() {
//                @Override
//                public void OnBannerClick(int i) {
//
//                }
//            });
        } catch (NotExistException e) {
            e.printStackTrace();
        } catch (WrongTypeException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    private void initview() {
        main_banner = (Banner) findComponentById(ResourceTable.Id_main_banner);
    }


    @Override
    public void onActive() {
        super.onActive();
    }

    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }
}
